package com.xian.historyDistines.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xian.common.annotation.Log;
import com.xian.common.core.controller.BaseController;
import com.xian.common.core.domain.AjaxResult;
import com.xian.common.enums.BusinessType;
import com.xian.historyDistines.domain.THistoricalDynasties;
import com.xian.historyDistines.service.ITHistoricalDynastiesService;
import com.xian.common.utils.poi.ExcelUtil;
import com.xian.common.core.page.TableDataInfo;

/**
 * 朝代简介Controller
 * 
 * @author ruoyi
 * @date 2025-04-04
 */
@RestController
@RequestMapping("/historyDistines/historyDistines")
public class THistoricalDynastiesController extends BaseController
{
    @Autowired
    private ITHistoricalDynastiesService tHistoricalDynastiesService;

    /**
     * 查询朝代简介列表
     */
    @PreAuthorize("@ss.hasPermi('historyDistines:historyDistines:list')")
    @GetMapping("/list")
    public TableDataInfo list(THistoricalDynasties tHistoricalDynasties)
    {
        startPage();
        List<THistoricalDynasties> list = tHistoricalDynastiesService.selectTHistoricalDynastiesList(tHistoricalDynasties);
        return getDataTable(list);
    }

    /**
     * 导出朝代简介列表
     */
    @PreAuthorize("@ss.hasPermi('historyDistines:historyDistines:export')")
    @Log(title = "朝代简介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, THistoricalDynasties tHistoricalDynasties)
    {
        List<THistoricalDynasties> list = tHistoricalDynastiesService.selectTHistoricalDynastiesList(tHistoricalDynasties);
        ExcelUtil<THistoricalDynasties> util = new ExcelUtil<THistoricalDynasties>(THistoricalDynasties.class);
        util.exportExcel(response, list, "朝代简介数据");
    }

    /**
     * 获取朝代简介详细信息
     */
    @PreAuthorize("@ss.hasPermi('historyDistines:historyDistines:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tHistoricalDynastiesService.selectTHistoricalDynastiesById(id));
    }

    /**
     * 新增朝代简介
     */
    @PreAuthorize("@ss.hasPermi('historyDistines:historyDistines:add')")
    @Log(title = "朝代简介", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody THistoricalDynasties tHistoricalDynasties)
    {
        return toAjax(tHistoricalDynastiesService.insertTHistoricalDynasties(tHistoricalDynasties));
    }

    /**
     * 修改朝代简介
     */
    @PreAuthorize("@ss.hasPermi('historyDistines:historyDistines:edit')")
    @Log(title = "朝代简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody THistoricalDynasties tHistoricalDynasties)
    {
        return toAjax(tHistoricalDynastiesService.updateTHistoricalDynasties(tHistoricalDynasties));
    }

    /**
     * 删除朝代简介
     */
    @PreAuthorize("@ss.hasPermi('historyDistines:historyDistines:remove')")
    @Log(title = "朝代简介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tHistoricalDynastiesService.deleteTHistoricalDynastiesByIds(ids));
    }
}
